<?php
include_once('common/header.php');
if($AppUI->id <= 0 || (isset($_SESSION['category']) && ($_SESSION['category'] <= 0))) {
	$this->_redirect(HOST_BACKEND);
}
$intLanguage	= $objRequest->getParam('lg', isset($_SESSION['lang']) ? $_SESSION['lang'] : 0);
$intType		= $objRequest->getParam('type', 0);
$intStatus		= $objRequest->getParam('stt', -1);
$strStart		= $objRequest->getParam('startdate', '');
$strEnd			= $objRequest->getParam('enddate', '');
$intPage		= $objRequest->getParam('page', 1);
$intCancel		= $objRequest->getParam('pcancel', 0);
$intLimit		= $variable['ADMIN_LIMIT']['val'];
$intOff			= (($intPage-1) * $intLimit);
$intTotal		= 0;
$objCategory	= new Category(); 
$arrResult		= $objCategory->getAll($AppUI->type, $intType, $intStatus, Ecore_Function::convertStrToDate($strStart), Ecore_Function::convertStrToDate($strEnd), $intOff, $intLimit, $intTotal);
if($strStart != '' || $strEnd != '') {
	$_SESSION['CATEGORY_CANCEL'] 	= 1;	
	$_SESSION['CATEGORY_POST']		= $objRequest->getParams();
}
else {
	if(isset($_SESSION['CATEGORY_POST'])) unset($_SESSION['CATEGORY_POST']);
	if(isset($_SESSION['CATEGORY_CANCEL'])) unset($_SESSION['CATEGORY_CANCEL']);
}
if($intCancel) {
	if(isset($_SESSION['CATEGORY_POST'])) unset($_SESSION['CATEGORY_POST']);
	if(isset($_SESSION['CATEGORY_CANCEL'])) unset($_SESSION['CATEGORY_CANCEL']);
}
# list
$this->view->arrResult		= $arrResult;
$this->view->intTotal		= $intTotal;
$this->view->intOffset		= $intOff;
$this->view->intLimit		= $intLimit;
$this->view->strUrl			= Ecore_Function::getUrl(HOST_BACKEND);
$this->view->arrStatus		= ($AppUI->type == ROOT_ROLE) ? $arrStatusAd : $arrStatus;
$this->view->intType		= $intType;